" Fibonacci function in Vim script (recursive)
function! FibonacciRecursive(n)
    if a:n <= 1
        return a:n
    else
        return FibonacciRecursive(a:n - 1) + FibonacciRecursive(a:n - 2)
    endif
endfunc

" Fibonacci function in Vim script (iterative)
function! FibonacciIterative(n)
    if a:n <= 1
        return a:n
    endif

    let a = 0
    let b = 1
    for i in range(2, a:n)
        let c = a + b
        let a = b
        let b = c
    endfor
    return b
endfunc

let n = 30
echo "Vim Script Fibonacci(" . n . ")"
" 测试递归实现
let start_time = reltime()
let fib_recursive = FibonacciRecursive(n)
echo "Recursive result: " . fib_recursive
let end_time = reltime(start_time)
echo "Recursive execution time: " . reltimestr(end_time) . " seconds"
" 测试迭代实现
let start_time = reltime()
let fib_iterative = FibonacciIterative(n)
echo "Iterative result: " . fib_iterative
let end_time = reltime(start_time)
echo "Iterative execution time: " . reltimestr(end_time) . " seconds"